package com.casa.POI.dianping;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.hibernate.Criteria;
import org.hibernate.Session;

public class GenerateCityList extends Executor {

	@SuppressWarnings("unchecked")
	@Override
	public void execute() {
		Session s = SessionManager.getInstance().openSession();
		Criteria c = s.createCriteria(City.class);
		List<City> cities = c.list();
		s.close();
		List<String> cityIds = new ArrayList<String>();
		for (City city : cities)
			cityIds.add(String.valueOf(city.getId()));
		String value = StringUtils.join(cityIds, ',');
		Console.writeLine(value);
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		new GenerateCityList().execute();
	}

}
